package com.example.studentcompetitionplatform.controller;

import com.example.studentcompetitionplatform.entity.Competitions;
import com.example.studentcompetitionplatform.entity.Reviews;
import com.example.studentcompetitionplatform.service.IReviewsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/zuopin")
public class ZuoPinPingShenController {
    @Resource
    private IReviewsService reviewsService;
    //新增
    @PostMapping("/register")
    public Integer register(@RequestBody Reviews reviews){
        reviewsService.insertR(reviews);
        return 1;
    }
    //删除
    @PostMapping("/del")
    public Integer delete(@RequestBody Reviews reviews){
        reviewsService.deleteR(reviews);
        return 1;
    }
    //编辑
    @PostMapping("/edit")
    public Integer edit(@RequestBody Reviews reviews){
        reviewsService.editR(reviews);
        return 1;
    }
    //分页数据查询
    @GetMapping("/page")
    public Map<String, Object> findPage(@RequestParam(value = "pageNum") Integer pageNum,
                                        @RequestParam(value = "pageSize") Integer pageSize,
                                        @RequestParam(value = "reviewId",required = false) Integer reviewId) {
        return reviewsService.page(pageNum,pageSize,reviewId);
    }
}
